const state = {
  userInfo: {
    name: 'Shio',
    age: 18
  },
  score: 100
}
const mutations = {
  changeUserName (state, newName) {
    state.userInfo.name = newName
  }
}
const actions = {
  changeAsyncName (context, newName) {
    setTimeout(() => {
      context.commit('changeUserName', newName)
    }, 1000)
  }
}
const getters = {
  // 模块中的参数state所指向的state为本模块内所声明的state
  UpperCaseName (state) {
    return state.userInfo.name.toUpperCase()
  }
}

export default {
  // 若需开启子模块映射需开启命名空间
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}
